整页开关入口与翻译态查询注入 (fix #325) - #354
Merged
Merged
Conversation
编排模块新增整页开关入口:一次调用完成查询翻译态、决定翻译或 还原、执行。翻译态查询与还原动作均为注入项,模块不触碰 DOM, 假注入可完整测试;内容脚本暂保留旧路径,行为不变。 Co-Authored-By: zhexuancai-uts <261878103+zhexuancai-uts@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
「查询当前翻译态 → 决定翻译还是还原 → 执行」的开关流程在内容脚本,没有可单测的模块入口。
根因
编排模块缺少整页开关入口,翻译态查询与还原动作没有注入面。
修复
编排模块新增
togglePage开关入口:翻译态查询(hasTranslated)与还原动作(restore)均为注入项,模块不直接访问 DOM,可在无 DOM 环境下用假注入完整测试;页面无译文时执行翻译(与translatePage同一条流水线),有译文时执行还原;内容脚本暂保留旧路径,用户可见行为不变。验证
pnpm typecheck通过;新增 5 个开关入口单测(无译文翻译、有译文还原零请求、假注入完整测试、准入拦截不执行动作、空 items),pnpm test626 个用例全部通过;pnpm build正常。Closes #325